/*
 * Copyright (c) 2020-2099 the original author or authors. All rights reserve.
 */
package org.tianyun.cloud.dashboard.service.impl;

import org.springframework.stereotype.Service;
import org.tianyun.cloud.common.domain.BaseDomain;
import org.tianyun.cloud.data.redis.annotation.FlushCache;
import org.tianyun.cloud.data.redis.annotation.SetCache;
import org.tianyun.cloud.dashboard.service.RedisCacheTestService;

import java.util.ArrayList;
import java.util.List;

/**
 * Redis
 *
 * @auther ebert_chan
 */
@Service
public class RedisCacheTestServiceImpl implements RedisCacheTestService {

    @SetCache(key = "redis:cache:test:{0}", variables = "#id", timeout = 30)
    @Override
    public List<BaseDomain> get(Long id) {
        List<BaseDomain> list = new ArrayList<>();
        BaseDomain d1 = new BaseDomain();
        d1.setId(1L);
        list.add(d1);

        BaseDomain d2 = new BaseDomain();
        d2.setId(2L);
        list.add(d2);
        return list;
    }

    @FlushCache(key = "redis:cache:test:{0}", variables = "#id")
    @Override
    public void delete(Long id) {
    }

}
